﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraTreeList;
using DevExpress.XtraTreeList.Nodes;
namespace Ebada.Modules.Document
{
    public partial class UCDocumentFindrejectDcoument : DevExpress.XtraEditors.XtraUserControl
    {
        public UCDocumentFindrejectDcoument()
        {
            InitializeComponent();
            ucDocumentPositionTree1.FocusedNodeChanged += new Ebada.Client.SendDataEventHandler<Ebada.Platform.Model.DocumentPosition>(ucDocumentPositionTree1_FocusedNodeChanged);
            ucDocumentPositionTree1.hidecolum();
            ucDocumentPositionTree1.hidebuttom();
            ucDocumentsB1.initColumns();
            ucDocumentsB1.Hide_Find();
            ucDocumentsB1.InitData();
            UCDocumentsB.FirstLoad = false;
        }

        void ucDocumentPositionTree1_FocusedNodeChanged(object sender, Ebada.Platform.Model.DocumentPosition obj)
        {
            splitCC1.Panel2.Text = "单证库位：" + (obj != null ? obj.PositionName : "");
            List<string> str_list = new List<string>();
            str_list = Nodes_Child(((TreeList)sender).FocusedNode, str_list);
            this.ucDocumentsB1.RefreshData(str_list);

        }
        private List<string> Nodes_Child(TreeListNode node, List<string> str_list)
        {
            if (node != null)
            {
                str_list.Add(node.GetValue("DocumentPositionID").ToString());
                if (node.Nodes.Count != 0)
                {
                    for (int i = 0; i < node.Nodes.Count; i++)
                    {
                        Nodes_Child(node.Nodes[i], str_list);
                    }
                }
            }
            return str_list;

        }
       
    }
}
